var grid = {
	init : function(){
		var boss = this;
		
		boss.initLayout();
		boss.initEvent();
	},
	initLayout : function(){
		var boss = this;

		$("#menu_tab div[tag]").hide();
		$("#con-tab-menu li[tag='jingli']").addClass("menu-tab-selected");
		$("div[tag='jingli']").show();
		$("#jljh, #jlleader, #jlzw").hide();
		$("#jltpcs, #jltjwq, #jltzrq").hide();
		$("#jqtpcs, #jqtjq, #jqtzrq").hide();
		$("#subgrid_count, #grid_list").hide();
		boss.initGridConditions();
		boss.showAllPolicePositionCountDB(boss.getFullId());
	},
	initEvent : function(){
		var boss = this;
		
		boss.initMenuTabEvent();
		boss.JWXXEvent();
		$("select[name='team']").bind("change", function(){
			var value = $(this).val();
			if(value == "0"){
				$("#jljh, #jlleader, #jlzw").show();
			}else{
				$("#jljh, #jlleader, #jlzw").hide();
			}
		});
		$("div[tag='jingli'] input[btn]").bind("click", function(){
			$("#grid_count, #subgrid_count").hide();
			var name = "";
			var mc = $("#name").val();
			var team = $("select[name]").val();
			var jh = $("#jh").val();
			var sex = $("input[name='sex']:checked").val();
			var card = $("#cardid").val();
			var phone = $("#phoneno").val();
			var fullid = boss.getFullId();
			var leader = $("#leader").val();
			var jw = $("#jw").val();
			var zd = $("input[name='zd']:checked").val();
			var app = $("input[name='app']:checked").val();
			if(team == ""){
				name = $("#xuanxiangka div[tag^='z'][selected]").last().find(".mc").html();
				alert("请选择队伍类型！");
			}else if(team == "0"){
				name = $("#xuanxiangka div[tag^='z'][selected]").last().find(".mc").html() + $("select[name] option[value='" + team + "']").html();
				boss.showPolicePeopleByConditions(mc, team, jh, sex, name, card, phone, fullid, leader, jw, zd, app, "");
			}else{
				name = $("#xuanxiangka div[tag^='z'][selected]").last().find(".mc").html() + $("select[name] option[value='" + team + "']").html();
				boss.showPolicePositionByConditions(mc, team, sex, card, phone, fullid, jw, zd, app, "", name);
			}
		});
		$("div[tag='jingwuxinxi'] input[btn]").bind("click", function(){
			$("#grid_count, #subgrid_count").hide();
			var jwxx = $("#jingwuxinxi-type").val();
			var dz = $("#jwxxdz").val();
			var ldbm = $("#jwxxldbm").val();
			var isqbcz = $("input[name='qbcz']:checked").val();
			var isdt = $("input[name='dt']:checked").val();
			var ishhcz = $("input[name='hhcz']:checked").val();
			var ismj = $("input[name='mj']:checked").val();
			var fullid = boss.getFullId();
			if(jwxx == "t1"){
				boss.showApartmentByConditions(dz, ldbm, isqbcz, isdt, ishhcz, ismj, fullid, "");
			}else if(jwxx == "t2"){
				
			}
		});
	},
	initMenuTabEvent : function(){
		var boss = this;
		$("#con-tab-menu li").bind("click", function(){
			var tag = $(this).attr("tag");
			$("#con-tab-menu li").removeClass("menu-tab-selected");
			$(this).addClass("menu-tab-selected");
			$("#menu_tab div[tag]").hide();
			$("div[tag='" + tag + "']").show();
			boss.switchMenuTab(tag);
		});
	},
	initGridConditions : function(){
		var tag = $("#xuanxiangka div[tag^='z'][selected]").last().attr("tag");
		var pid = $("#xuanxiangka div[tag^='z'][selected]").last().attr("pid");
		$("#jltpcs, #jltjwq, #jltzrq").hide();
		$("#jqtpcs, #jqtjq, #jqtzrq").hide();
		if(tag == "z1") {
			$("#jltpcs, #jltjwq, #jltzrq").show();
			$("#jqtpcs, #jqtjq, #jqtzrq").show();
		}else if(tag == "z2"){
			$("#jltjwq, #jltzrq").show();
			$("#jqtjq, #jqtzrq").show();
		}else if(tag == "z3"){
			$("#jltzrq").show();
			$("#jqtzrq").show();
		}
	},
	switchMenuTab : function(tag){
		var boss = this;
		if(tag == "jingli"){
			boss.showAllPolicePositionCountDB(boss.getFullId());
		} else if(tag == "jingqing"){
			boss.showAlertGrid();
		} else if(tag == "jingwuxinxi"){
			$("tr[tag]").hide();
			$("tr[tag='search_czw_xinxi']").show();
			boss.showAllApartmentCountDB();
		}
	},
	MenuTab : function(){
		var boss = this;
		var tag = $("#con-tab-menu li[class='menu-tab-selected']").attr("tag");
		if(tag == "jingli"){
			boss.showAllPolicePositionCountDB(boss.getFullId());
		}else if(tag == "jingqing"){
			boss.showAlertGrid();
		}else if(tag == "jingwuxinxi"){
			boss.showAllApartmentCountDB();
		}
	},
	showPolicePeopleByConditions : function(mc, team, jh, sex, name, card, phone,
			fullid, leader, jw, zd, app, pageIndex){
		var boss = this;
		$.ajax({
			dataType: 'json',
			type: 'post',
			data: {xm: mc, team: team, jh: jh,
				sex: sex, card: card, phone: phone,
				fullid: fullid, leader: leader, jw: jw,
				zd: zd, app: app, grid_pageSize: null,
				grid_pageIndex: pageIndex, grid_order: 'id'},
			url: burl + '/policeInfo/getModelByConditions.do',
			success: function(data){
				var data1 = data.data;
				var maxPage = Math.ceil(data.total/data.pageSize);
				var htmlContent = "<table class='people-grid' id='people-grid'>";
				htmlContent += "<tr><th colspan='5'>" + name + "</th></tr>";
				for(var i = 0; i < data1.length; i++){
					var row = data1[i];
					htmlContent += "<tr no='" + row.id + "'>";
					htmlContent += "<td style='text-aligh: right;'>";
					htmlContent += "<img onerror='error(this)' src='"+burl +"/images"+ boss.getImgFile(row.photoUrl) + "' />";
					htmlContent += "</td><td>";
					htmlContent += "<span>姓名：" + row.name + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>岗位：" + row.position + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>工作单位：" + row.unit + "</span>";
					htmlContent += "</td>";
					htmlContent += "<td class='caozuotubiao' no='" + row.id + "'>";
					htmlContent += "<div><a href='#' ht='instruction'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/instruction.png' title='指令'/>";
					htmlContent += "</a><a href='#' ht='location'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/location.png' title='定位'/>";
					htmlContent += "</a><a href='#' ht='detail'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/detail.png' title='详情'/>";
					htmlContent += "</a></div>";
					htmlContent += "</td></tr>";
				}
				htmlContent += "<tr id='pageShow'><td colspan='5' class='pageTr'><span pageIndex='1'>首页";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) - 1, maxPage) + "' id='before'>上一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) + 1, maxPage) + "' id='next'>下一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + maxPage + "'>尾页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "当前第<a href=''>" + data.pageIndex + "</a>页&nbsp;/&nbsp;共" + maxPage + "页";
				htmlContent += "</td></tr></table>";
				$("#grid_list").html(htmlContent);
				$("#grid_list").show();
				$("#grid_list").css("margin-top", "20px");
				boss.PolicePositionTableTrEvent();
				$("#people-grid a").bind("click", function(){
					var ht = $(this).attr("ht");
					if(ht == "instruction"){
						
					} else if(ht == "location"){
						var no = $(this).parents("td").attr("no");
						window.location.href = burl + "/view/main/map.jsp?no=" + no;
					} else if(ht == "detail"){
						var no = $(this).parents("td").attr("no");
						window.open(burl + "/policeInfo/getModelById.do?id=" + no, "", "height=480,width=750,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
					}
					return false;
				});
				$("#pageShow span[pageIndex]").bind("click", function(){
					var pageIn = $(this).attr("pageIndex");
					boss.showPolicePeopleByConditions(mc, team, jh, sex, name, card, phone, fullid, leader, jw, zd, app, pageIn);
				});
			}
		});
	},
	showPolicePositionByConditions : function(mc, team, sex, card, phone, fullid, jw, zd, app, pageIndex, name){
		var boss = this;
		$.ajax({
			dataType: 'json',
			type: 'post',
			data: {xm: mc, team: team, sex: sex, card: card,
				phone: phone, fullid: fullid, jw: jw, zd: zd,
				app: app, grid_pageSize: null, grid_pageIndex: pageIndex,
				grid_order: 'id'},
			url: burl + '/QFQZModel/getModelByConditions.do',
			success: function(data){
				var data1 = data.data;
				var maxPage = Math.ceil(data.total/data.pageSize);
				var htmlContent = "<table class='people-grid' id='people-grid'>";
				htmlContent += "<tr><th colspan='5'>" + name + "</th></tr>";
				for(var i = 0; i < data1.length; i++){
					var row = data1[i];
					htmlContent += "<tr no='" + row.id + "'>";
					htmlContent += "<td style='text-aligh: right;'>";
					htmlContent += "<img src='" + burl + "/images/nohead.png' />";
					htmlContent += "</td><td>";
					htmlContent += "<span>姓名：" + row.personName + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>岗位：" + row.personWork + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>工作单位：" + row.unitName + "</span>";
					htmlContent += "</td>";
					htmlContent += "<td class='caozuotubiao' no='" + row.id + "'>";
					htmlContent += "<div><a href='#' ht='instruction'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/instruction.png' title='指令'/>";
					htmlContent += "</a><a href='#' ht='location'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/location.png' title='定位'/>";
					htmlContent += "</a><a href='#' ht='detail'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/detail.png' title='详情'/>";
					htmlContent += "</a></div>";
					htmlContent += "</td></tr>";
				}
				htmlContent += "<tr id='pageShow'><td colspan='5' class='pageTr'><span pageIndex='1'>首页";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) - 1, maxPage) + "' id='before'>上一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) + 1, maxPage) + "' id='next'>下一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + maxPage + "'>尾页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "当前第<a href=''>" + data.pageIndex + "</a>页&nbsp;/&nbsp;共" + maxPage + "页";
				htmlContent += "</td></tr></table>";
				$("#grid_list").html(htmlContent);
				$("#grid_list").show();
				$("#grid_list").css("margin-top", "20px");
				boss.PolicePositionTableTrEvent();	
				$("#people-grid a").bind("click", function(){
					var ht = $(this).attr("ht");
					if(ht == "instruction"){
						prompt("请输入指令","");
						alert("命令发送成功.");
					} else if(ht == "location"){
						window.location.href = burl + "/view/main/map.jsp?operation=showPoliceInMap";
					} else if(ht == "detail"){
						var no = $(this).parents("td").attr("no");
						window.open(burl + "/QFQZModel/details.do?id=" + no, "", "height=480,width=750,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
					}
					return false;
				});
				$("#pageShow span[pageIndex]").bind("click", function(){
					var pageIn = $(this).attr("pageIndex");
					boss.showPolicePositionByConditions(mc, team, sex, card, phone, fullid, jw, zd, app, pageIn, name);
				});
			}
		});
	},
	showApartmentByConditions : function(dz, ldbm, isqbcz, isdt, ishhcz, ismj, fullid, pageIndex){
		var boss = this;
		$.ajax({
			dataType: 'json',
			type: 'post',
			data: {dz: dz, ldbm: ldbm, isqbcz: isqbcz, isdt: isdt,
				ishhcz: ishhcz, ismj: ismj, fullid: fullid,
				grid_pageSize: null, grid_pageIndex: pageIndex,
				grid_order: 'takedate desc'},
			url: burl + '/Apartment/getModelByGridConditions.do',
			success: function(data){
				var data1 = data.data;
				var maxPage = Math.ceil(data.total/data.pageSize);
				var htmlContent = "<table class='people-grid' id='people-grid'>";
				for(var i = 0; i < data1.length; i++){
					var row = data1[i];
					htmlContent += "<tr id='" + boss.getFieldValue(row.ID) + "'>";
					htmlContent += "<td>";
					htmlContent += "<img src='http://ba110.cn/" + boss.getFieldValue(row.SMALLIMGURL) + "' /></td>";
					htmlContent += "<td>";
					htmlContent += "<span>地址：" + boss.getFieldValue(row.CZWDZ) + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>类型：" + boss.getFieldValue(row.BUILDING_TYPE) + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>社区民警姓名：" + boss.getFieldValue(row.ZRMJXM) + "</span>";
					htmlContent += "</td><td class='caozuotubiao'>";
					htmlContent += "<div><a href='#'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/edit.png' title='纠错'/>";
					htmlContent += "</a>";
					htmlContent += "<a href='#'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/detail.png' title='详情'/>";
					htmlContent += "</a>";
					htmlContent += "<a href='#' tag='" + row.TID + "'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/location.png' title='定位'/>";
					htmlContent += "</a>";
					htmlContent += "<img  style='height:80px;width:80px' src='../code' />" ; 
					htmlContent += "</td></tr>";
				}
				htmlContent += "<tr id='pageShow'><td colspan='5' class='pageTr'><span pageIndex='1'>首页";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) - 1, maxPage) + "' id='before'>上一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) + 1, maxPage) + "' id='next'>下一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + maxPage + "'>尾页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "当前第<a href=''>" + data.pageIndex + "</a>页&nbsp;/&nbsp;共" + maxPage + "页";
				htmlContent += "</td></tr></table>";
				$("#grid_list").html(htmlContent);
				$("#grid_list").show();
				$("#grid_list").css("margin-top", "20px");
				$("#pageShow span[pageIndex]").bind("click", function(){
					var pageIn = $(this).attr("pageIndex");
					boss.showApartmentByConditions(dz, ldbm, isqbcz, isdt, ishhcz, ismj, fullid, pageIn);
				});
				$("#pageShow span[pageIndex]").bind("mouseenter", function(){
					$(this).css("color", "#ff0000");
				});
				$("#pageShow span[pageIndex]").bind("mouseleave", function(){
					$(this).css("color", "#0000ff");
				});
				boss.ApartmentTableTrEvent();
			}
		});
	},
	showAllPolicePositionCountDB : function(fullid){
		var boss = this;
		$.ajax({
			dataType: 'json',
			type: 'post',
			url: burl + '/QFQZModel/getCountByOrg.do?fullid=' + fullid,
			success: function(data){
				var count = 0;
				var sum = 0;
				var num = 0;
				var htmlContent = "<table class='Count-grid' id='Count-grid'>";
				for(var i = 0; i < data.length; i++){
					count += boss.getValue(data[i].COUNT);
					sum += boss.getValue(data[i].SUM);
					num += boss.getValue(data[i].NUM);
				}
				htmlContent += "<tr><th>队伍名称</th><th>数量(人)</th><th>可指挥数(终端数)</th><th>安装App数(人)</th><th>巡逻里程/计划巡逻里程</th><th>分布</th></tr>";
				htmlContent += "<tr><td>总人数</td><td><span tag='all'>" + count + "</span></td>";
				htmlContent += "<td><span zd='all'>" + sum + "</span></td><td><span app='all'>" + num + "</span></td><td></td><td><img src='" + burl + "/images/grid-images/location.png' hg='all' /></td>";
				for(var i = 0; i < data.length; i++){
					var row = data[i];
					if(row.UNIT_CODE == "0"){
						htmlContent += "<tr><td>民警</td><td><span tag='0'>" + boss.getValue(row.COUNT) + "</span></td>";
						htmlContent += "<td><span zd='0'>" + boss.getValue(row.SUM) + "</span></td><td><span app='0'>" + boss.getValue(row.NUM) + "</span></td><td>23/30(km)</td><td><img src='" + burl + "/images/grid-images/location.png' hg='0' /></td>";
					} 
				}
				for(var i = 0; i < data.length; i++){
					var row = data[i];
					if(row.UNIT_CODE == "1"){
						htmlContent += "<tr><td>第一支队伍</td><td><span tag='1'>" + boss.getValue(row.COUNT) + "</span></td>";
						htmlContent += "<td><span zd='1'>" + boss.getValue(row.SUM) + "</span></td><td><span app='1'>" + boss.getValue(row.NUM) + "</span></td><td>22/27(km)</td><td><img src='" + burl + "/images/grid-images/location.png' hg='1' /></td>";
					}
				} 
				for(var i = 0; i < data.length; i++){
					var row = data[i];
					if(row.UNIT_CODE == "2"){
						htmlContent += "<tr><td>第二支队伍</td><td><span tag='2'>" + boss.getValue(row.COUNT) + "</span></td>";
						htmlContent += "<td><span zd='2'>" + boss.getValue(row.SUM) + "</span></td><td><span app='2'>" + boss.getValue(row.NUM) + "</span></td><td>13/17(km)</td><td><img src='" + burl + "/images/grid-images/location.png' hg='2' /></td>";
					}
				}
				for(var i = 0; i < data.length; i++){
					var row = data[i]; 
					if(row.UNIT_CODE == "3"){
						htmlContent += "<tr><td>第三支队伍</td><td><span tag='3'>" + boss.getValue(row.COUNT) + "</span></td>";
						htmlContent += "<td><span zd='3'>" + boss.getValue(row.SUM) + "</span></td><td><span app='3'>" + boss.getValue(row.NUM) + "</span></td><td>15/16(km)</td><td><img src='" + burl + "/images/grid-images/location.png' hg='3' /></td>";
					}
				}
				for(var i = 0; i < data.length; i++){
					var row = data[i];
					if(row.UNIT_CODE == "4"){
						htmlContent += "<tr><td>第四支队伍</td><td><span tag='4'>" + boss.getValue(row.COUNT) + "</span></td>";
						htmlContent += "<td><span zd='4'>" + boss.getValue(row.SUM) + "</span></td><td><span app='4'>" + boss.getValue(row.NUM) + "</span></td><td>0/0(km)</td><td><img src='" + burl + "/images/grid-images/location.png' hg='4' /></td>";
					}
				}
				for(var i = 0; i < data.length; i++){
					var row = data[i];
					if(row.UNIT_CODE == "5"){
						htmlContent += "<tr><td>第五支队伍</td><td><span tag='5'>" + boss.getValue(row.COUNT) + "</span></td>";
						htmlContent += "<td><span zd='5'>" + boss.getValue(row.SUM) + "</span></td><td><span app='5'>" + boss.getValue(row.NUM) + "</span></td><td>7/10(km)</td><td><img src='" + burl + "/images/grid-images/location.png' hg='5' /></td>";
					}
				}
				htmlContent += "</table>"; 
				htmlContent += "<div class='closeTable' id='closeTable'><img src='" + burl + "/images/grid-images/closeBtn.png' /></div>";
				$("#grid_count").html(htmlContent);
				$("#grid_count").show();
				$("#subgrid_count, #grid_list").hide();
				$("#Count-grid span[tag]").bind("click", function(){
					var team = $(this).attr("tag");
					var org = $("#xuanxiangka div[tag^='z'][selected]").last().find(".mc").html();
					if(team == "all"){
						boss.showPolicePositionGrid("", "", boss.getFullId(), org + "总人数列表");
						$("#subgrid_count").hide();
					} else if(team == "0"){
						boss.showPolicePeopleGrid(org + "民警");
						$("#subgrid_count").hide();
					}else{
						boss.showSubPolicePositionCountDB(team);
						$("#subgrid_count").show();
						$("#grid_list").hide();
					}
				});
				$("#Count-grid span[zd]").bind("click", function(){
					var zd = $(this).attr("zd");
					var team = $(this).parents("tr").find("span[tag]").attr("tag");
					if(zd == "all"){
						
					} else if(zd == "0"){
						
					} else {
						boss.showSubPolicePositionCountDB(team);
						$("#subgrid_count").show();
						$("#grid_list").hide();
					}
					$("#grid_list").show();
					$("#Count-grid").hide();
					$("#closeTable").attr("selected", "selected");
					$("#closeTable img").attr("src", burl + "/images/grid-images/openBtn.png");
				});
				$("#Count-grid span[app]").bind("click", function(){
					var app = $(this).attr("app");
					var team = $(this).parents("tr").find("span[tag]").attr("tag");
					if(app == "all"){
						
					} else if(app == "0"){
						
					} else {
						boss.showSubPolicePositionCountDB(team);
						$("#subgrid_count").show();
						$("#grid_list").hide();
					}
					$("#grid_list").show();
					$("#Count-grid").hide();
					$("#closeTable").attr("selected", "selected");
					$("#closeTable img").attr("src", burl + "/images/grid-images/openBtn.png");
				});
				$("#Count-grid span").bind("mouseenter", function(){
					$(this).css("color", "#0000ff");
				});
				$("#Count-grid span").bind("mouseleave", function(){
					$(this).css("color", "#FA5454");
				});
				$("#Count-grid img[hg]").bind("click", function(){
					var hg = $(this).attr("hg");
					window.location.href = burl + "/view/main/map.jsp?operation=showPoliceDW&dw=" + hg;
				});
				boss.ImgClick();
			}
		});
	},
	showAllApartmentCountDB : function(){
		var boss = this;
		var fullid = boss.getFullId();
		$.ajax({
			dataType: 'json',
			type: 'post',
			data: {orgid: fullid},
			url: burl + '/Apartment/getAll.do',
			success: function(data){
				var count = 0;
				for(var i = 0; i < data.length; i++){
					count += data[i].NUM;
				}
				var htmlContent = "<table class='Count-grid1' id='Count-grid'>";
				htmlContent += "<tr><th>出租屋楼栋类型</th><th>数量（栋）</th><th>分布</th></tr>";
				htmlContent += "<tr><td>楼栋总数</td><td><span tag='all'>" + count + "</span></td><td><img src='" + burl + "/images/grid-images/location.png' hg='all' /></td></tr>";
				for(var i = 0; i < data.length; i++){
					var row = data[i];
					if(row.TYPE == "1"){
						htmlContent += "<tr><td>物业式小区</td>";
						htmlContent += "<td><span tag='" + row.TYPE + "'>" + row.NUM + "</span></td>";
						htmlContent += "<td><img src='" + burl + "/images/grid-images/location.png' hg='all' /></td></tr>";
					}
				}
				for(var i = 0; i < data.length; i++){
					var row = data[i];	
					if(row.TYPE == "2"){
						htmlContent += "<tr><td>城中村小区</td>";
						htmlContent += "<td><span tag='" + row.TYPE + "'>" + row.NUM + "</span></td>";
						htmlContent += "<td><img src='" + burl + "/images/grid-images/location.png' hg='all' /></td></tr>";
					}
				}
				for(var i = 0; i < data.length; i++){
					var row = data[i];	
					if(row.TYPE == "3"){
						htmlContent += "<tr><td>其他(独栋)</td>";
						htmlContent += "<td><span tag='" + row.TYPE + "'>" + row.NUM + "</span></td><td><img src='" + burl + "/images/grid-images/location.png' hg='all' /></td></tr>";
					}
				}
				htmlContent += "</table>";
				htmlContent += "<div class='closeTable' id='closeTable'><img src='" + burl + "/images/grid-images/closeBtn.png' /></div>";
				$("#grid_count").html(htmlContent);
				$("#subgrid_count, #grid_list").hide();
				$("#grid_count").show();
				$("#Count-grid span[tag]").bind("click", function(){
					var tag = $(this).attr("tag");
					boss.showApartmentGrid(tag, "");
					$("#Count-grid").hide();
					$("#closeTable").attr("selected", "selected");
					$("#closeTable img").attr("src", burl + "/images/grid-images/openBtn.png");
				});
				$("#Count-grid span").bind("mouseenter", function(){
					$(this).css("color", "#0000ff");
				});
				$("#Count-grid span").bind("mouseleave", function(){
					$(this).css("color", "#FA5454");
				});
				boss.ImgClick();
			}
		});
	},
	showSubPolicePositionCountDB : function(team){
		var boss = this;
		var org = $("#xuanxiangka div[tag^='z'][selected]").last().find(".mc").html();
		var fullid = boss.getFullId();
		$("#grid_list").empty();
		$.ajax({
			dataType: 'json',
			type: 'post',
			data: {fullid: fullid, team: team},
			url: burl + '/QFQZModel/getSubCount.do',
			success: function(data){
				var htmlContent = "<table class='sub_count' id='sub_count'>";
				htmlContent += "<tr><th>单位实际名称</th><th>保（治）安人员(人)</th><th>可指挥数(终端数)</th><th>安装App数(人)</th><th>分布</th></tr>";
				for(var i = 0; i < data.length; i++){
					var row = data[i];
					htmlContent += "<tr subTag='" + row.UNIT_NAME + "'><td>" + row.UNIT_NAME + "</td>";
					htmlContent += "<td><span>" + row.COUNT + "</span></td>";
					htmlContent += "<td><span zd='是'>" + row.SUM + "</span></td>";
					htmlContent += "<td><span app='是'>" + row.NUM + "</span></td>";
					htmlContent += "<td><img src='" + burl + "/images/grid-images/location.png' hg='" + row.UNIT_NAME + "' /></td></tr>";
				}
				htmlContent += "</table>";
				htmlContent += "<div class='closeTable' id='closeSubTable'><img src='" + burl + "/images/grid-images/closeBtn.png' /></div>";
				$("#subgrid_count").html(htmlContent);
				$("#subgrid_count").show();
				$("#grid_list").hide();
				$("#Count-grid").hide();
				$("#closeTable").attr("selected", "selected");
				$("#closeTable img").attr("src", burl + "/images/grid-images/openBtn.png");
				$("#subgrid_count span").bind("click", function(){
					var unit_name = $(this).parents("tr").attr("subTag");
					var zd = $(this).attr("zd");
					var app = $(this).attr("app");
					$("#grid_list").show();
					boss.showPolicePositionGridByUnit(unit_name, team, zd, app, boss.getFullId(), org + unit_name);
					$("#Count-grid, #sub_count").hide();
					$("#closeSubTable").attr("selected", "selected");
					$("#closeSubTable img").attr("src", burl + "/images/grid-images/openBtn.png");
				});
				$("#closeSubTable").bind("click", function(){
					var selected = $(this).attr("selected");
					if(selected){
						$("#sub_count").show();
						$(this).removeAttr("selected");
						$("#closeSubTable img").attr("src", burl + "/images/grid-images/closeBtn.png");
					} else {
						$("#sub_count").hide();
						$("#closeSubTable img").attr("src", burl + "/images/grid-images/openBtn.png");
						$(this).attr("selected", "selected");
					}
				});
				$("#sub_count img[hg]").bind("click", function(){
					var hg = $(this).attr("hg");
					window.open(burl + "/view/map/SendOrder.jsp?dw="+hg+"", "", "height=608,width=1056,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
				});
				$("#sub_count span").bind("mouseenter", function(){
					$(this).css("color", "#0000ff");
				});
				$("#sub_count span").bind("mouseleave", function(){
					$(this).css("color", "#FA5454");
				});
			}
		});
	},
	showPolicePositionGridByUnit : function(unitName, team, zd, app, orgid, mc, pageIndex){
		var boss = this;
		$.ajax({
			dataType: 'json',
			type: 'post',
			data:{unit_name: unitName, team:team, zd: zd, app: app, fullid: orgid, grid_pageSize: null, grid_pageIndex: pageIndex, grid_order: "id"},
			url: burl + '/QFQZModel/getPersonByCons.do',
			success: function(data){
				var data1 = data.data;
				var maxPage = Math.ceil(data.total/data.pageSize);
				var htmlContent = "<table class='people-grid' id='people-grid'>";
				htmlContent += "<tr><th colspan='5'>" + mc + "</th></tr>";
				for(var i = 0; i < data1.length; i++){
					var row = data1[i];
					htmlContent += "<tr no='" + row.ID + "'>";
					htmlContent += "<td style='text-aligh: right;'>";
					htmlContent += "<img src='" + burl + "/images/nohead.png' />";
					htmlContent += "</td><td>";
					htmlContent += "<span>姓名：" + row.NAME + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>岗位：" + row.POSITION + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>工作单位：" + row.UNIT + "</span>";
					htmlContent += "</td>";
					htmlContent += "<td class='caozuotubiao' no='" + row.ID + "'>";
					htmlContent += "<div><a href='#' ht='instruction'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/instruction.png' title='指令'/>";
					htmlContent += "</a><a href='#' ht='location'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/location.png' title='定位'/>";
					htmlContent += "</a><a href='#' ht='detail'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/detail.png' title='详情'/>";
					htmlContent += "</a></div>";
					htmlContent += "</td></tr>";
				}
				htmlContent += "<tr id='pageShow'><td colspan='5' class='pageTr'><span pageIndex='1'>首页";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) - 1, maxPage) + "' id='before'>上一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) + 1, maxPage) + "' id='next'>下一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + maxPage + "'>尾页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "当前第<a href=''>" + data.pageIndex + "</a>页&nbsp;/&nbsp;共" + maxPage + "页";
				htmlContent += "</td></tr></table>";
				$("#grid_list").html(htmlContent);
				$("#grid_list").css("margin-top", "20px");
				boss.PolicePositionTableTrEvent();
				$("#people-grid a").bind("click", function(){
					var ht = $(this).attr("ht");
					if(ht == "instruction"){
						prompt("请输入指令","");
						alert("命令发送成功.");
					} else if(ht == "location"){
						window.location.href = burl + "/view/main/map.jsp?operation=showPoliceInMap";
					} else if(ht == "detail"){
						var no = $(this).parents("td").attr("no");
						window.open(burl + "/QFQZModel/details.do?id=" + no, "", "height=480,width=750,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
					}
					return false;
				});
				$("#pageShow span[pageIndex]").bind("click", function(){
					var pageIndex = $(this).attr("pageIndex");
					boss.showPolicePositionGridByUnit(unitName, team, orgid, mc, pageIndex);
				});
			}
		});
	},
	showPolicePositionGrid : function(subType, team, orgid, mc, pageIndex){
		var boss = this;
		$.ajax({
			dataType: 'json',
			type: 'post',
			data:{sub_type:subType, team:team, fullid: orgid, grid_pageSize: null, grid_pageIndex: pageIndex, grid_order: "id"},
			url: burl + '/QFQZModel/getPersonByCons.do',
			success: function(data){
				var data1 = data.data;
				var maxPage = Math.ceil(data.total/data.pageSize);
				var htmlContent = "<table class='people-grid' id='people-grid'>";
				htmlContent += "<tr><th colspan='5'>" + mc + "</th></tr>";
				for(var i = 0; i < data1.length; i++){
					var row = data1[i];
					htmlContent += "<tr no='" + row.ID + "'>";
					htmlContent += "<td style='text-aligh: right;'>";
//					htmlContent += "<img src='" + burl + "/images/nohead.png' />";
					htmlContent += "<img onerror='error(this)' src='"+burl +"/images"+ boss.getImgFile(row.IMG) + "' />";
					htmlContent += "</td><td>";
					htmlContent += "<span>姓名：" + row.NAME + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>岗位：" + boss.getFieldValue(row.POSITION) + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>工作单位：" + boss.getFieldValue(row.UNIT) + "</span>";
					htmlContent += "</td>";
					htmlContent += "<td class='caozuotubiao' no='" + row.ID + "' code='" + row.UCODE + "'>";
					htmlContent += "<div><a href='#' ht='instruction'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/instruction.png' title='指令'/>";
					htmlContent += "</a><a href='#' ht='location'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/location.png' title='定位'/>";
					htmlContent += "</a><a href='#' ht='detail'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/detail.png' title='详情'/>";
					htmlContent += "</a></div>";
					htmlContent += "</td></tr>";
				}
				htmlContent += "<tr id='pageShow'><td colspan='5' class='pageTr'><span pageIndex='1'>首页";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) - 1, maxPage) + "' id='before'>上一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) + 1, maxPage) + "' id='next'>下一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + maxPage + "'>尾页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "当前第<a href=''>" + data.pageIndex + "</a>页&nbsp;/&nbsp;共" + maxPage + "页";
				htmlContent += "</td></tr></table>";
				$("#grid_list").html(htmlContent);
				$("#grid_list").show();
				$("#Count-grid").hide();
				$("#closeTable").attr("selected", "selected");
				$("#closeTable img").attr("src", burl + "/images/grid-images/openBtn.png");
				$("#grid_list").css("margin-top", "20px");
				boss.PolicePositionTableTrEvent();
				$("#people-grid a").bind("click", function(){
					var ht = $(this).attr("ht");
					var ucode = $(this).parents("td").attr("code");
					if(ht == "instruction"){
						prompt("请输入指令","");
						alert("命令发送成功.");
					} else if(ht == "location"){
						window.location.href = burl + "/view/main/map.jsp?operation=showPoliceInMap";
					} else if(ht == "detail"){
						var no = $(this).parents("td").attr("no");
						if(ucode == "0"){
							window.open(burl + "/policeInfo/getModelById.do?id=" + no, "", "height=480,width=750,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
						}else {
							window.open(burl + "/QFQZModel/details.do?id=" + no, "", "height=480,width=750,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
						}
					}
					return false;
				});
				$("#pageShow span[pageIndex]").bind("click", function(){
					var pageIndex = $(this).attr("pageIndex");
					boss.showPolicePositionGrid(subType, team, orgid, mc, pageIndex);
				});
			}
		});
	},
	showPolicePeopleGrid : function(mc, pageIndex){
		var boss = this;
		var org = boss.getFullId();
		$.ajax({
			dataType: 'json',
			type: 'post',
			data: {orgcode : org, grid_pageSize: null, grid_pageIndex: pageIndex},
			url: burl + '/policeInfo/getGridByOrg.do',
			success: function(data){
				var data1 = data.data;
				var maxPage = Math.ceil(data.total/data.pageSize);
				var htmlContent = "<table class='people-grid' id='people-grid'>";
				htmlContent += "<tr><th colspan='5'>" + mc + "</th></tr>";
				for(var i = 0; i < data1.length; i++){
					var row = data1[i];
					htmlContent += "<tr no='" + row.id + "'>";
					htmlContent += "<td style='text-aligh: right;'>";
					htmlContent += "<img onerror='error(this)' src='"+burl +"/images"+ boss.getImgFile(row.photoUrl) + "' />";
					htmlContent += "</td><td>";
					htmlContent += "<span>姓名：" + row.name + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>岗位：" + row.position + "</span>";
					htmlContent += "</td><td>";
					htmlContent += "<span>工作单位：" + row.unit + "</span>";
					htmlContent += "</td>";
					htmlContent += "<td class='caozuotubiao' no='" + row.id + "'>";
					htmlContent += "<div><a href='#' ht='instruction'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/instruction.png' title='指令'/>";
					htmlContent += "</a><a href='#' ht='location'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/location.png' title='定位'/>";
					htmlContent += "</a><a href='#' ht='detail'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/detail.png' title='详情'/>";
					htmlContent += "</a></div>";
					htmlContent += "</td></tr>";
				}
				htmlContent += "<tr id='pageShow'><td colspan='5' class='pageTr'><span pageIndex='1'>首页";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) - 1, maxPage) + "' id='before'>上一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) + 1, maxPage) + "' id='next'>下一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + maxPage + "'>尾页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "当前第<a href=''>" + data.pageIndex + "</a>页&nbsp;/&nbsp;共" + maxPage + "页";
				htmlContent += "</td></tr></table>";
				$("#grid_list").html(htmlContent);
				$("#grid_list").show();
				$("#Count-grid").hide();
				$("#closeTable").attr("selected", "selected");
				$("#closeTable img").attr("src", burl + "/images/grid-images/openBtn.png");
				$("#grid_list").css("margin-top", "20px");
				boss.PolicePositionTableTrEvent();
				$("#people-grid a").bind("click", function(){
					var ht = $(this).attr("ht");
					if(ht == "instruction"){
						
					} else if(ht == "location"){
						var no = $(this).parents("td").attr("no");
						window.location.href = burl + "/view/main/map.jsp?no=" + no;
					} else if(ht == "detail"){
						var no = $(this).parents("td").attr("no");
						window.open(burl + "/policeInfo/getModelById.do?id=" + no, "", "height=480,width=750,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
					}
					return false;
				});
				$("#pageShow span[pageIndex]").bind("click", function(){
					var pageIndex = $(this).attr("pageIndex");
					boss.showPolicePeopleGrid(mc, pageIndex);
				});
			}
		});
	},
	showApartmentGrid : function(tag, pageIndex){
		var boss = this;
		var org = boss.getFullId();
		$.ajax({
			dataType: 'json',
			type: 'post',
			data: {orgid: org, type: tag, grid_pageSize: null, grid_pageIndex: pageIndex, grid_order: 'takedate desc'},
			url: burl + '/Apartment/getModelByOrgGrid.do',
			success: function(data){
				var data1 = data.data;
				var maxPage = Math.ceil(data.total/data.pageSize);
				var htmlContent = "<table class='people-grid' id='people-grid'>";
				for(var i = 0; i < data1.length; i++){
					var row = data1[i];
					htmlContent += "<tr id='" + boss.getFieldValue(row.ID) + "'>";
					htmlContent += "<td>";
					if(row.OS == null){
						htmlContent += "<img src='" + sbl.getBaseUrl() + "/" + boss.getFieldValue(row.SMALLIMGURL) + "' />";
					}else {
						htmlContent += "<img src='http://ba110.cn" + boss.getFieldValue(row.SMALLIMGURL) + "' /></td>";
					}			
					htmlContent += "<td>";
					if(row.ADDR == null){
						htmlContent += "<span>地址：" + boss.getFieldValue(row.CZWDZ) + "</span>";
					}else{
						htmlContent += "<span>地址：" + boss.getFieldValue(row.ADDR) + "</span>";
					}
					htmlContent += "</td><td>";
					if(row.BUILDING_TYPE == "1"){
						htmlContent += "<span>类型：物业式小区</span>";
					}else if(row.BUILDING_TYPE == "2"){
						htmlContent += "<span>类型：城中村小区</span>";
					}else{
						htmlContent += "<span>类型：其他(独栋)</span>";
					}
					htmlContent += "</td><td>";
					htmlContent += "<span>社区民警姓名：</span>";
					htmlContent += "<td><span>"+ boss.getFieldValue(row.ZRMJXM) + "</span></td>";
					htmlContent += "</td><td class='caozuotubiao'>";
					
					htmlContent += "<div><a href='#' hg='edit'>";
					
					htmlContent += "<img src='" + burl + "/images/grid-images/edit.png' title='纠错'/>";
					htmlContent += "</a>";
					htmlContent += "<a href='#' no='" + row.TID + "' hg='detail'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/detail.png' title='详情'/>";
					htmlContent += "</a>";
					htmlContent += "<a href='#' tag='" + row.TID + "' hg='location'>";
					htmlContent += "<img src='" + burl + "/images/grid-images/location.png' title='定位'/>";
					htmlContent += "</a></div>";
					
					htmlContent += "</td>";
					htmlContent += "<td>";
					htmlContent += "<img  style='height:80px;width:80px' src='../code?ewmurl="+burl+"/Termpost/getTermpostModel.do?id="+row.TID+"'> " 
					htmlContent += "</td></tr>";
				}
				htmlContent += "<tr id='pageShow'><td colspan='5' class='pageTr'><span pageIndex='1'>首页";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) - 1, maxPage) + "' id='before'>上一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + boss.getPage(parseInt(data.pageIndex) + 1, maxPage) + "' id='next'>下一页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "<span pageIndex='" + maxPage + "'>尾页</span>";
				htmlContent += "</span>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;";
				htmlContent += "当前第<a href=''>" + data.pageIndex + "</a>页&nbsp;/&nbsp;共" + maxPage + "页";
				htmlContent += "</td></tr></table>";
				$("#grid_list").html(htmlContent);
				$("#grid_list").css("margin-top", "20px");
				$("#grid_list").show();
				$("#pageShow span[pageIndex]").bind("mouseenter", function(){
					$(this).css("color", "#ff0000");
				});
				$("#pageShow span[pageIndex]").bind("mouseleave", function(){
					$(this).css("color", "#0000ff");
				});
				$("#pageShow span[pageIndex]").bind("click", function(){
					var pageIn = $(this).attr("pageIndex");
					boss.showApartmentGrid(tag, pageIn);
				});
				boss.ApartmentTableTrEvent();
			}
		});
	},
	showAlertGrid : function(){
		var boss = this;
		$("#grid_list").empty();
		var code = 0;
		var pid = $("#xuanxiangka div[tag^='z'][selected]").last().attr("pid");
		var tag = $("#xuanxiangka div[tag^='z'][selected]").last().attr("tag");
		for(var i = 1; i < 5; i++){
			if(tag == "z" + i){
				code = i + 2;
			}
		}
		$.ajax({
			dataType: 'json',
			type: 'post',
			data: {orgcode: pid, code: code},
			url: burl + '/policeCaseTModel/getAllByOrg.do',
			success: function(data){
				var htmlContent = "<table class='people-grid' id='people-grid'>";
				htmlContent += "<tr><th>事件发生区域</th><th>有效警情</th><th>违法犯罪</th><th>刑事</th><th>治安</th>";
				htmlContent += "<th>八类</th><th>两抢</th><th>抢劫</th><th>飞车抢夺</th><th>盗窃总</th>";
				htmlContent += "<th>入室盗窃</th><th>盗窃汽车</th><th>盗窃摩托车/电动</th><th>诈骗</th><th>分布</th></tr>";
				for(var i = 0; i < data.length; i++){
					var row = data[i];
					htmlContent += "<tr pid='" + row.fulldeptid + "'>";
					htmlContent += "<td tag='name'>" + row.deptname + "</td>";
					htmlContent += "<td><span>" + row.effectiveCase + "</span></td>";
					htmlContent += "<td><span>" + row.illegalCrime + "</span></td>";
					htmlContent += "<td><span>" + row.criminal + "</span></td>";
					htmlContent += "<td><span>" + row.publicOrder + "</span></td>";
					htmlContent += "<td><span>" + row.eightCategory + "</span></td>";
					htmlContent += "<td><span>" + row.rob + "</span></td>";
					htmlContent += "<td><span>" + row.robbery + "</span></td>";
					htmlContent += "<td><span>" + row.robberyByCar + "</span></td>";
					htmlContent += "<td><span>" + row.theftOfAll + "</span></td>";
					htmlContent += "<td><span>" + row.theftInRoom + "</span></td>";
					htmlContent += "<td><span>" + row.theftCar + "</span></td>";
					htmlContent += "<td><span>" + row.theftMoto + "</span></td>";
					htmlContent += "<td><span>" + row.fraud + "</span></td>";
					htmlContent += "<td><img src='" + burl + "/images/grid-images/location.png' title='定位' /></td>";
					htmlContent += "</tr>";
				}
				htmlContent += "</table>";
				htmlContent += "<div class='closeTable' id='closeTable'><img src='" + burl + "/images/grid-images/closeBtn.png' /></div>";
				$("#grid_count").html(htmlContent);
				$("#people-grid").css("margin-bottom", "20px");
				$("#people-grid span").css("color", "#FA5454");
				$("#people-grid img").css("width", "15px");
				$("#people-grid img").css("height", "15px");
				$("#subgrid_count, #grid_list").hide();
				$("#grid_count").show();
				boss.JQImgClick();
				boss.AlertTableTrEvent();
				$("#people-grid span").bind("mouseenter", function(){
					$(this).css("color", "#0000ff");
				});
				$("#people-grid span").bind("mouseleave", function(){
					$(this).css("color", "#FA5454");
				});
			}
		});
	},
	showZDRYGrid : function(){
		var boss = this;
		$.ajax({
			dataType: 'json',
			type: 'post',
			url: burl + '/ZDRYModel/getZDRYModel.do',
			success: function(data){
				var htmlContent = "<table class='people-grid' id='people-grid'>";
				for(var i = 0; i < data.length; i++){
					var row = data[i];
					htmlContent += "<tr no='" + row.id + "'>";
					htmlContent += "<td style='text-aligh: right;'>";
					htmlContent += "<img src='" + burl + "/images/nohead.png' />";
					htmlContent += "</td><td>";
					htmlContent += "<div><span>姓名：" + row.personName + "</span></div>";
					htmlContent += "<div><span>性别：" + boss.getSexValue(row.personSex) + "</span></div>";
					htmlContent += "<div><span>身份证号：" + row.personcardno + "</span></div>";
					htmlContent += "</td>";
					htmlContent += "<td style='width:100px;'>";
					htmlContent += "<div><a href='#'>指令</a></div>";
					htmlContent += "<div><a href='#'>详情</a></div>";
					htmlContent += "</td></tr>";
				}
				htmlContent += "</table>";
				$("#grid_list").html(htmlContent);
				boss.TableTrEvent();
			}
		});
	},
	JQImgClick : function(){
		$("#closeTable").bind("click", function(){
			var selected = $(this).attr("selected");
			if(selected){
				$("#people-grid").show();
				$(this).removeAttr("selected");
				$("#closeTable img").attr("src", burl + "/images/grid-images/closeBtn.png");
			} else {
				$("#people-grid").hide();
				$("#closeTable img").attr("src", burl + "/images/grid-images/openBtn.png");
				$(this).attr("selected", "selected");
			}
		});
	},
	ImgClick : function(){
		$("#closeTable").bind("click", function(){
			var selected = $(this).attr("selected");
			if(selected){
				$("#Count-grid").show();
				$(this).removeAttr("selected");
				$("#closeTable img").attr("src", burl + "/images/grid-images/closeBtn.png");
			} else {
				$("#Count-grid").hide();
				$("#closeTable img").attr("src", burl + "/images/grid-images/openBtn.png");
				$(this).attr("selected", "selected");
			}
		});
	},
	JWXXEvent : function(){
		var boss = this;
		$("#jingwuxinxi-type").bind("change", function(){
			var type = $(this).val();
			if(type == "t1"){
				$("tr[tag]").hide();
				$("tr[tag='search_czw_xinxi']").show();
				boss.showApartmentGrid();
			} else if(type == "t2"){
				$("tr[tag]").hide();
				$("tr[tag='search_zdry_xinxi']").show();
				boss.showZDRYGrid();
			}
		});
	},
	PolicePositionTableTrEvent : function(){
		var boss = this;
		$("#people-grid tr").bind("click", function(){
			
		});
		boss.TableTrMouseEnterEvent();
	},
	ApartmentTableTrEvent : function(){
		var boss = this;
		$("#people-grid a[hg]").bind("click", function(){
			var no = $(this).attr("no");
			var tid = $(this).attr("tag");
			var hg = $(this).attr("hg");
			if(hg == "location"){
				window.location.href=burl + "/view/main/map.jsp?operation=showApartmentInMap&id=" + tid;
			}else if(hg == "detail"){
				window.open(burl + "/buildingModel/getModel.do?id=" + no,"","height=480,width=750,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
			}
			return false;
		});
		boss.TableTrMouseEnterEvent();
		$("#people-grid a[tag]").bind("click", function(){
		});
	},
	AlertTableTrEvent : function(){
		var boss = this;
		$("#people-grid tr").bind("click", function(){
			var pid = $(this).attr("pid").split("-");
			var name = $(this).find("td[tag='name']").html();
			if(pid.length == 5){
				boss.SecondTable(pid, name);
			}else if(pid.length == 4){
				$.ajax({
					dataType: 'json',
					type: 'post',
					data: {orgcode: pid[2], code: pid.length},
					url: burl + '/policeCaseTModel/getAllByOrg.do',
					success: function(data){
						var htmlContent = "<table class='thrid-people-grid' id='thrid-people-grid'>";
						htmlContent += "<tr><th colspan='15'>" + name + "</th></tr>";
						htmlContent += "<tr><th>事件发生区域</th><th>有效警情</th><th>违法犯罪</th><th>刑事</th><th>治安</th>";
						htmlContent += "<th>八类</th><th>两抢</th><th>抢劫</th><th>飞车抢夺</th><th>盗窃总</th>";
						htmlContent += "<th>入室盗窃</th><th>盗窃汽车</th><th>盗窃摩托车/电动</th><th>诈骗</th><th>分布</th></tr>";
						for(var i = 0; i < data.length; i++){
							var row = data[i];
							htmlContent += "<tr pid='" + row.fulldeptid + "'>";
							htmlContent += "<td tag='name'>" + row.deptname + "</td>";
							htmlContent += "<td><span>" + row.effectiveCase + "</span></td>";
							htmlContent += "<td><span>" + row.illegalCrime + "</span></td>";
							htmlContent += "<td><span>" + row.criminal + "</span></td>";
							htmlContent += "<td><span>" + row.publicOrder + "</span></td>";
							htmlContent += "<td><span>" + row.eightCategory + "</span></td>";
							htmlContent += "<td><span>" + row.rob + "</span></td>";
							htmlContent += "<td><span>" + row.robbery + "</span></td>";
							htmlContent += "<td><span>" + row.robberyByCar + "</span></td>";
							htmlContent += "<td><span>" + row.theftOfAll + "</span></td>";
							htmlContent += "<td><span>" + row.theftInRoom + "</span></td>";
							htmlContent += "<td><span>" + row.theftCar + "</span></td>";
							htmlContent += "<td><span>" + row.theftMoto + "</span></td>";
							htmlContent += "<td><span>" + row.fraud + "</span></td>";
							htmlContent += "<td><img src='" + burl + "/images/grid-images/location.png' title='定位' /></td>";
							htmlContent += "</tr>";
						}
						htmlContent += "</table>";
						htmlContent += "<div class='closeTable' id='closeSubTable'><img src='" + burl + "/images/grid-images/closeBtn.png' /></div>";
						$("#subgrid_count").html(htmlContent);
						$("#subgrid_count").show();
						$("#thrid-people-grid img").css("width", "15px");
						$("#thrid-people-grid img").css("height", "15px");
						$("#thrid-people-grid").css("margin-top", "20px");
						$("#thrid-people-grid").css("margin-bottom", "20px");
						$("#thrid-people-grid span").css("color", "#FA5454");
						$("#closeSubTable").bind("click", function(){
							var selected = $(this).attr("selected");
							if(selected){
								$("#thrid-people-grid").show();
								$(this).removeAttr("selected");
								$("#closeSubTable img").attr("src", burl + "/images/grid-images/closeBtn.png");
							} else {
								$("#thrid-people-grid").hide();
								$("#closeSubTable img").attr("src", burl + "/images/grid-images/openBtn.png");
								$(this).attr("selected", "selected");
							}
						});
						$("#thrid-people-grid span").bind("mouseenter", function(){
							$(this).css("color", "#0000ff");
						});
						$("#thrid-people-grid span").bind("mouseleave", function(){
							$(this).css("color", "#FA5454");
						});
						$("#thrid-people-grid tr").bind("mouseenter", function(){
							$(this).css("background-color", "#F9F9F9");
							$(this).css("cursor", "pointer");
							$(this).siblings().css("background-color", "#fff");
						});
						$("#thrid-people-grid tr").bind("click", function(){
							var subpid = $(this).attr("pid").split("-");
							var subname = $(this).find("td[tag='name']").html();
							$("#grid_list").empty();
							boss.SecondTable(subpid, subname);
							$("#thrid-people-grid").hide();
							$("#closeSubTable").attr("selected", "selected");
							$("#closeSubTable img").attr("src", burl + "/images/grid-images/openBtn.png");
						});
					}
				});
			}
			$("#people-grid").hide();
			$("#closeTable").attr("selected", "selected");
			$("#closeTable img").attr("src", burl + "/images/grid-images/openBtn.png");
		});
		boss.TableTrMouseEnterEvent();
	},
	SecondTable : function(pid, name){
		$.ajax({
			dataType: 'json',
			type: 'post',
			data: {orgcode: pid[3], code: pid.length},
			url: burl + '/policeCaseTModel/getAllByOrg.do',
			success: function(data){
				var htmlContent = "<table class='sub-people-grid' id='sub-people-grid'>";
				htmlContent += "<tr><th colspan='15'>" + name + "</th></tr>";
				htmlContent += "<tr><th>事件发生区域</th><th>有效警情</th><th>违法犯罪</th><th>刑事</th><th>治安</th>";
				htmlContent += "<th>八类</th><th>两抢</th><th>抢劫</th><th>飞车抢夺</th><th>盗窃总</th>";
				htmlContent += "<th>入室盗窃</th><th>盗窃汽车</th><th>盗窃摩托车/电动</th><th>诈骗</th><th>分布</th></tr>";
				for(var i = 0; i < data.length; i++){
					var row = data[i];
					htmlContent += "<tr pid='" + row.fulldeptid + "'>";
					htmlContent += "<td>" + row.deptname + "</td>";
					htmlContent += "<td>" + row.effectiveCase + "</td>";
					htmlContent += "<td>" + row.illegalCrime + "</td>";
					htmlContent += "<td>" + row.criminal + "</td>";
					htmlContent += "<td>" + row.publicOrder + "</td>";
					htmlContent += "<td>" + row.eightCategory + "</td>";
					htmlContent += "<td>" + row.rob + "</td>";
					htmlContent += "<td>" + row.robbery + "</td>";
					htmlContent += "<td>" + row.robberyByCar + "</td>";
					htmlContent += "<td>" + row.theftOfAll + "</td>";
					htmlContent += "<td>" + row.theftInRoom + "</td>";
					htmlContent += "<td>" + row.theftCar + "</td>";
					htmlContent += "<td>" + row.theftMoto + "</td>";
					htmlContent += "<td>" + row.fraud + "</td>";
					htmlContent += "<td><img src='" + burl + "/images/grid-images/location.png' title='定位' /></td>";
					htmlContent += "</tr>";
				}
				htmlContent += "</table>";
				$("#grid_list").html(htmlContent);
				$("#sub-people-grid").css("margin-top", "20px");
				$("#sub-people-grid img").css("width", "15px");
				$("#sub-people-grid img").css("height", "15px");
				$("#grid_list").show();
				$("#sub-people-grid tr").bind("mouseenter", function(){
					$(this).css("background-color", "#F9F9F9");
					$(this).css("cursor", "pointer");
					$(this).siblings().css("background-color", "#fff");
				});
			}
		});
	},
	TableTrMouseEnterEvent : function(){
		$("#people-grid tr").bind("mouseenter", function(){
			$(this).css("background-color", "#F9F9F9");
			$(this).css("cursor", "pointer");
			$(this).siblings().css("background-color", "#fff");
		});
	},
	getFieldValue : function(value){
		if(value == null){
			return "";
		} else {
			return value;
		}
	},
	getValue : function(value){
		if(value == null){
			return 0;
		} else {
			return value;
		}
	},
	getImgFile : function(value){
		if(value == null){
			return "/images/upload/police/nohead.png";
		} else {
			return value;
		}
	},
	getIdFromMain : function(){
		var id = $("#xuanxiangka div[tag^='z'][selected]").last().attr("pid");
		var pid = "";
		if(id == 1){
			pid = "";
		}else{
			pid = id;
		}
		return pid;
	},
	getSexValue : function(value){
		if(value == "1"){
			return "男";
		} else if(value == "2") {
			return "女";
		}
	},
	getFullId : function(){
		var fullid = $("#xuanxiangka div[tag^='z'][selected]").last().attr("fullid");
		return fullid;
	},
	initTableSize : function(){
		var tableWidth = $("#grid_main").outerWidth();
		var tableHeight = $("#grid_main").outerHeight();
		$("#people-grid").css("width", tableWidth);
		$("#people-grid").css("height", tableHeight);
	},
	getPage : function(value, maxPage){
		if(value == 0){
			return 1;
		}else if(value > maxPage){
			return maxPage;
		}else{
			return value;
		}
	}
};
function error(img){
	$(img).attr("src",burl+"/images/upload/police/nohead.png");
};